package com.hmall.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.pojo.Item;
import org.apache.ibatis.annotations.Update;

public interface ItemMapper extends BaseMapper<Item> {
    /**
     * 减少商品库存
     * @param itemId
     * @param num
     */
    @Update("update tb_item set stock = stock - #{num} where id = #{itemId}")
    void deduct(Long itemId, Integer num);

    /**
     * 回滚商品
     * @param itemId
     * @param num
     */
    @Update("update tb_item set stock = stock + #{num} where id = #{itemId}")
    void refund(String itemId, String num);
}
